﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp2
{
    class ghost
    {
        private int SpeedX ;
        private int SpeedY;
        public Rectangle Rectangle { get; set; }
        public ghost(Rectangle rec)
        {
            Rectangle = rec;
            SpeedX = 10;
            SpeedY = 10;
        }
        public void Draw(Graphics g)
        {
            g.DrawImage(Properties.Resources.pinkghost, Rectangle);
        }
        public void Move(Size size)
        {
            this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y, Rectangle.Width, Rectangle.Height);
            if(this.Rectangle.X<0)
            {
                this.Rectangle = new Rectangle(0, this.Rectangle.Y, Rectangle.Width, Rectangle.Height);
                SpeedX = -SpeedX;
            }
            if (this.Rectangle.X+this.Rectangle.Width >size.Width)
            {
                this.Rectangle = new Rectangle(size.Width-this.Rectangle.Width, this.Rectangle.Y, Rectangle.Width, Rectangle.Height);
                SpeedX = -SpeedX;
            }
        }

    }
}
